#pragma once
#include <Blobz.h>
#include "Graphics/3D/Node.h"

namespace Tutorial6
{
	struct FingerStorage
	{
		FingerStorage(TouchListener::TouchData inData)
		{
			mFinger = inData;
			mLink = NULL;
			mTimeDown = 0;
		}
		void Update(float inFrameTime)
		{
			if(mLink!=NULL && mTimeDown>-1)
			{
				mTimeDown+=inFrameTime;
			}
		}

		void link(Blobz::Node *inNode)
		{
			mLink = inNode;
			mTimeDown = 0;
		}

		float mTimeDown;
		Blobz::Node *mLink;
		TouchListener::TouchData mFinger;
	};

	// A simple class for handle multitouch gestures and touch points. It also provides methods for calculate delta position and angle changes in gestures.
	class FingerManager
	{
	public:
		FingerManager();
		~FingerManager();	
	
	private:
		FingerManager(const FingerManager& that);
		FingerManager& operator=(const FingerManager& that);

	public:
		void onFingerDown(const TouchListener::TouchData& inData);
		void onFingerUp(const TouchListener::TouchData& inData);
		void onFingerUpdate(const TouchListener::TouchData& inData);

		FingerStorage* findFinger(int inID);
		void clearFingers() { mFingers.clear(); }
		void removeFinger(int inID);
		float distanceChange();
		float angleChange();

	private:
		std::list<FingerStorage> mFingers;
		
	};
}